### 使用kubesphere的base基础镜像进行构建，https://github.com/kubesphere/devops-agent/blob/master/base/Dockerfile
### 其基础镜像为centos:7
FROM kubesphere/builder-maven:v3.2.0

ENV SCALA_VERSION=2.12.16
# 安装scala
RUN yum -y localinstall https://downloads.lightbend.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.rpm

CMD ["scala","-version"]
# 安装sbt
RUN rm -f /etc/yum.repos.d/bintray-rpm.repo && \
    curl -L https://www.scala-sbt.org/sbt-rpm.repo > sbt-rpm.repo && \
    mv sbt-rpm.repo /etc/yum.repos.d/ && \
    yum -y install sbt
RUN mkdir -p ~/.sbt
COPY conf/repositories ~/.sbt/
CMD ["sbt","-version"]

# 安装python3
ENV PYTHON_VERSION=3.7.11
RUN yum -y install bzip2-devel libffi-devel libsqlite3x-devel && \
        curl -fSL https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz -o /usr/src/Python-${PYTHON_VERSION}.tgz && \
        tar xzf /usr/src/Python-${PYTHON_VERSION}.tgz -C /usr/src/ --no-same-owner && \
        cd /usr/src/Python-${PYTHON_VERSION} && \
        ./configure --enable-optimizations --with-ensurepip=install --enable-loadable-sqlite-extensions && \
        make altinstall -j 2 && \
        cd ../ && \
        rm -rf /usr/src/Python-${PYTHON_VERSION}.tgz /usr/src/Python-${PYTHON_VERSION} && \
        ln -fs /usr/local/bin/python3.7 /usr/bin/python && \
        ln -fs /usr/local/bin/python3.7 /usr/bin/python3 && \
        ln -fs /usr/local/bin/pip3.7 /usr/bin/pip && \
        python3 -m pip install --upgrade pip && \
        sed -e 's|^#!/usr/bin/python|#!/usr/bin/python2.7|g' -i.bak /usr/bin/yum && \
        sed -e 's|^#! /usr/bin/python|#! /usr/bin/python2.7|g' -i.bak /usr/libexec/urlgrabber-ext-down && \
        yum -y remove bzip2-devel libffi-devel libsqlite3x-devel && \
        yum -y clean all

CMD ["python","--version"]
